package com.acmetelecom.call;

import org.joda.time.DateTime;

import com.acmetelecom.customer.Customer;

public class Call {
	private CallEvent start;
	private CallEvent end;

	public Call(CallEvent start, CallEvent end) {
		this.start = start;
		this.end = end;
	}

	public Customer callee() {
		return start.getCallee();
	}

	public long durationSeconds() {
		return (end.time().getMillis() - start.time().getMillis()) / 1000;
	}

	public String date() {
		return start.time().toString("d/M/yy h:mma").toLowerCase();
	}

	public DateTime startTime() {
		return start.time();
	}

	public DateTime endTime() {
		return end.time();
	}

	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}
		if (other instanceof Call) {
			Call call = (Call) other;
			return call.end.equals(end) && call.start.equals(start);
		}
		return false;
	}

	public int hashCode() {
		return end.hashCode();
	}
}
